/*
 * StrahlentherapieGeneralParticleSource.cc
 *
 *  Created on: Dez 14, 2010
 *      Author: hoba
 */

#include "StrahlentherapieGeneralParticleSource.hh" 

StrahlentherapieGeneralParticleSource::StrahlentherapieGeneralParticleSource() : G4GeneralParticleSource()
{
	energyHist = new map<int, int>();
}

StrahlentherapieGeneralParticleSource::~StrahlentherapieGeneralParticleSource()
{
	delete energyHist;
}

void StrahlentherapieGeneralParticleSource::PrintEnergyHist() {
	map<int, int>::iterator it1;
	
	for(it1 = energyHist->begin(); it1 != energyHist->end(); it1++) {
		G4cout << "ESHIST\t" << it1->first << "\t" << it1->second << G4endl;
	}
}

void StrahlentherapieGeneralParticleSource::GeneratePrimaryVertex(G4Event * evt) {
	this->G4GeneralParticleSource::GeneratePrimaryVertex(evt);
	
	int erg = floor(this->GetCurrentSource()->GetParticleEnergy()/keV);
	(*energyHist)[erg] += 1;
}
